package storage.beans;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class GridBean {
  private long dateTime;
  private Map cells;
  private Iterator cellIterator;
  
  public GridBean() {
    cells = new HashMap();
  }
  
  /**
   * Initializes an iterator over the set of CellBean objects contained in this bean.
   */
  public void initCellIterator() {
    cellIterator = cells.keySet().iterator();
  }
  
  /**
   * GridBean.initCellIterator() should be called before calling this for the first time.
   * @return null if there are no more CellBean objects to return
   */
  public CellBean getNextCell() {
    if(cellIterator.hasNext())
      return (CellBean)cells.get(cellIterator.next());
    else
      return null;
  }
  
  public void addCell(CellBean cell) {
    String key = cell.getLatitude() + "-" + cell.getLongitude();
    cells.put(key, cell);
  }
  
  public long getDateTime() {
    return dateTime;
  }
  
  public void setDateTime(long dateTime) {
    this.dateTime = dateTime;
  }
  
}
